<?php

/**
 * 任务模块
 * */

namespace App\Http\Controllers;

use App\Http\Model\Hint;
use App\Http\Model\OutJson;
use App\Http\Model\Room;
use App\Http\Model\System;
use App\Http\Services\CounterServices;
use App\Http\Services\FinancePayServices;
use App\Http\Services\FinanceRechargeOrderServices;
use App\Http\Services\UserServices;
use Illuminate\Http\Request;
use App\Lib\Response;

class CounterController extends BaseController
{
    protected $servicesCounter;
    protected $serviceFinanceRechargeOrder;
    protected $userServices;

    public function __construct(FinanceRechargeOrderServices $financeRechargeOrderServices)
    {
        $this->servicesCounter = new CounterServices();
        $this->serviceFinanceRechargeOrder = $financeRechargeOrderServices;
        $this->userServices = new UserServices();
    }

    /**
     * 货架-更新或创建
     * */
    public function updateOrInsertCounter()
    {
        do {
            if (!$this->checkRequest(false)) {
                break;
            }

            $this->callCommon($this->servicesCounter, 'updateOrInsertCounter', $this->requestData);

        } while (false);

        $this->responseData();
    }

    /**
     * 货架-删除
     * */
    public function removeCounter()
    {
        do {
            if (!$this->checkRequest(false)) {
                break;
            }

            $this->callCommon($this->servicesCounter, 'removeCounter', $this->requestData);

        } while (false);

        $this->responseData();
    }

    /**
     * 货架分类-更新或创建
     * */
    public function updateOrInsertCounterCate()
    {
        do {
            if (!$this->checkRequest(false)) {
                break;
            }

            $this->callCommon($this->servicesCounter, 'updateOrInsertCounterCate', $this->requestData);

        } while (false);

        $this->responseData();
    }

    /**
     * 货架分类-删除
     * */
    public function removeCounterCate()
    {
        do {
            if (!$this->checkRequest(false)) {
                break;
            }

            $this->callCommon($this->servicesCounter, 'removeCounterCate', $this->requestData);

        } while (false);

        $this->responseData();
    }

    public function createOrUpdateCounterNewPlay(Request $request) {
        $counterId = $request->post('counter_id', 0);
        $playDesc = $request->post('play_desc', '');
        // $playUrl = $request->post('play_url', '');
        // $playIcon = $request->post('play_icon', '');
        $playBg = $request->post('play_bakground_pic', '');
        $id = $request->post('id', 0);
        $isDel = $request->post('is_del', 0);
        if(0 === $counterId || '' === $playDesc || '' === $playBg) return OutJson::outJsonNoData(Hint::PARAM_ERROR);

        $this->servicesCounter->createOrUpdateCounterNewPlay($request->except('_url'), $id, $isDel);
        OutJson::outJsonNoData(Hint::SUCCESS);
    }

}
